
<style>
    .salam{
        border:1px solid #000;
    }
</style>
<div class="navbar">
    <div class="navbar-content">

        <a href="/" class="element" style="font-size:24px"><span class="icon-monitor"></span> BPJS Ketenagakerjaan <sub>(Sistem Antrian ver v.0.1a)</sub></a>

        <div class="no-tablet-portrait">
            <div class="element place-right">
                <a class="dropdown-toggle" href="#">
                    <span class="icon-cog"></span>
                </a>
                <ul class="dropdown-menu place-right" data-role="dropdown">
                     <li><a href="<?php echo base_url("c_login/logout"); ?>"><i class="icon-exit"></i> Logout</a></li>
                </ul>
            </div>
        </div>
    </div>
</div>

<div class="container offset2">
    
    
<div class="grid">
    
    <div class="row">
        <div class="span6 bg-amber padding20 text-left">
            <span class="fg-white">
                Selamat Datang 
                <b><?php echo $_SESSION[SESSION_USERFULLNAME]; ?></b> <br />
                Anda di Loket <?php echo $_SESSION[SESSION_LOKETNOMOR]; ?> Pelayanan <?php echo $_SESSION[SESSION_LOKETNAMA]; ?>
            </span>
        </div>
        <div class="offset2 span4 bg-red padding20 text-center">
            <audio id="play" autoplay autobuffer ></audio>
            <center style="font-weight:bold;color:white;">
                Panggilan Terakhir :
                <br/><span id="last_service">-</span>
            </center>
        </div>
    </div>
     
    <div class="row">
        <div class="span12" id="realtime">  
        </div>
    </div>
</div>

</div>

    <input type="hidden" value="<?php  echo ($loket_transfer->num_rows() > 0) ? $loket_transfer->row('loket_transfer') : "";?>" name="loket_transfer"  id="loket_transfer" placeholder="Loket Transfer"/>

<script type="text/javascript">
   function realtime(){
        $.ajax({
            url:"<?php  echo base_url("loket/listAllAntrian/".$kode."")?>",
            success: function(response){
                $("#realtime").html(response);
                 setTimeout("realtime()",2000);
                <?php if ($loket_transfer->num_rows() <= 0) { ?>
                    $(".transfer").hide();
                <?php } ?>
            }
        });
    }
   
    realtime();
    function selanjutnya(id,ke){
        $.ajax({
            url :"<?php  echo base_url("loket/selanjutnya/")?>",
            type:"POST",
            data: {
                pengunjung_id  : id,
                panggilan_ke  : ke,
            },
            success:function(response){
           //     realtime();
            }
        });
    }
    
    function selesai(id){
        $.ajax({
            url :"<?php  echo base_url("loket/selesai/")?>",
            type:"POST",
            data: {
                pengunjung_id  : id
            },
            success:function(response){
         //       realtime();
            }
        });
    }
    
    function  hadir(id,query){
        $.ajax({
            url :"<?php  echo base_url("loket/hadir/")?>",
            type:"POST",
            data: {
                pengunjung_id  : id,
                pengunjung_hadir: query,
            },
            success:function(response){
         //       realtime();
            }
        });
    }
    function transfer(nomor,id){
        $.ajax({
            url :"<?php  echo base_url("loket/transfer/")?>",
            type:"POST",
            data: {
                pengunjung_id  : id,
                nomor_antrian  : nomor,
                loket_transfer : $("#loket_transfer").val()
            },
            success: function(response){
                realtime();
                var r = response;
               
                 $.Dialog({
                    overlay: true,
                    shadow: true,
                    flat: true,
                    title: 'Nomor Antrian Anda',
                    content: '',
                    onShow: function(_dialog){
                        var content = _dialog.children('.content');
                        content.html('<div class="example"><h1>'+r+'</h1></div>');
                    }
                });
            }
        })
    }
    var a, j; 
    function sound(id){
    var play =  document.getElementById("play");
        $.ajax({
            url:"<?php  echo base_url("dashboard/antrian")?>",
            data :{
                pengunjung_id : id
            },
            dataType : "json",
            success: function(response){
                if (response.spel != ""){
                    a = response.spel.split(" ");
                    j = 0;
                    console.log(j);
                    play.src = "assets/audio/"+a[j]+".wav";
                    play.play();
                    play.onended  = function(){
                            j++;
                        if (j < a.length){
                            play.src = "assets/audio/"+a[j]+".wav";
                            play.play();
                        }
                    }
                }
            }
        });
    }
</script>